package com.kc.web.controller.business;

import com.kc.business.domain.BizTourguide;
import com.kc.business.service.IBizTourguideService;
import com.kc.common.annotation.Log;
import com.kc.common.annotation.RepeatSubmit;
import com.kc.common.core.controller.BaseController;
import com.kc.common.core.domain.AjaxResult;
import com.kc.common.core.page.TableDataInfo;
import com.kc.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * TODO
 *
 * @author zhangshuo
 * @version 1.0
 * @date 2020/9/10
 */
@RestController
@RequestMapping("/business/tourguide")
public class BizTourguideController extends BaseController {
    @Autowired
    private IBizTourguideService bizTourguideService;

    /**
     * 导游列表
     *
     * @param bizTourguide
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:tourguide:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizTourguide bizTourguide) {
        startPage();
        List<BizTourguide> list = bizTourguideService.getList(bizTourguide);
        return getDataTable(list);
    }

    /**
     * 修改导游
     *
     * @param bizTourguide
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:tourguide:edit')")
    @Log(title = "导游管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @RepeatSubmit
    public AjaxResult edit(@RequestBody BizTourguide bizTourguide) {
        if (bizTourguide.getId() != null && bizTourguide.getId() > 0) {
            bizTourguide.setUpdateTime(new Date());
            return toAjax(bizTourguideService.edit(bizTourguide));
        }
        return AjaxResult.error("请指定要修改的导游信息ID");
    }
}
